import React from "react";
import {ModalForm, ProFormDatePicker, ProFormText} from "@ant-design/pro-form/es";
import {Space} from "antd";

const BusInfoForm: React.FC = (props: any) => {
  return (
    <ModalForm<Domain.Bus>
      title={props.title}
      trigger={props.trigger}
      autoFocusFirstInput
      modalProps={{
        onCancel: () => console.log('run'),
      }}
      onFinish={async (values) => {
        if (props.handleAdd)
          return await props.handleAdd(values)
        if (props.handleUpdate)
          return await props.handleUpdate(props.bus.busNum, values)
      }}
      layout="horizontal"
      labelCol={{span: 7}}
      wrapperCol={{span: 14}}
      initialValues={props.bus}
    >

      <Space direction={"vertical"} size={16}>
        <ProFormText
          width="md"
          name="busNum"
          label="车牌号"
          tooltip="七位的车牌号"
          placeholder="请输入车牌号"
          required
        />


        <ProFormText
          width="md"
          name="persons"
          label="载客数"
          placeholder="请输入载客数"
          required
        />

        <ProFormDatePicker
          name="buyDate"
          label="购进日期"
          width="md"
          required
        />

      </Space>
    </ModalForm>
  );
}

export default BusInfoForm;
